package edu.tsinghua.oxy.leader.controller;

import edu.tsinghua.oxy.common.entity.Result;
import edu.tsinghua.oxy.leader.service.IJobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 种子URL操作接口
 *
 * @author sean
 * @date 2021 - 07 - 30 上午11:47
 */
@Slf4j
@RestController
@RequestMapping("seed")
public class SeedController {

    @Resource
    IJobService jobService;

    /**
     * 增加爬取任务的接口
     * @param url
     * @return
     */
    @RequestMapping("add")
    public Result<Object> addSeed(String url) {
        return jobService.seedJob(url);
    }

    /**
     * 初始化任务（队列的接口）
     * @return
     */
    @RequestMapping("init")
    public Result<Object> initSeed() {
        jobService.initJob();
        return Result.success("初始化成功");
    }
}
